package com.oscar.web.service;

import com.oscar.web.dao.UserBookCollectRepository;
import com.oscar.web.dao.UserBookEvaluateRepository;
import com.oscar.web.domain.collect;
import com.oscar.web.domain.rating;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserBookCollectService {

    @Autowired
    private UserBookCollectRepository userBookCollectRepository;

    public String collectBook(collect userBookCollect){
        String msg="感谢您的收藏，我们将会继续为您推荐更优质的图书。";
        if (userBookCollectRepository.existsByUserIdAndBookId(userBookCollect.getUserId(),userBookCollect.getBookId())){
            msg="该图书您已评价了哦，无需再次评价。";
        }else{
            userBookCollectRepository.save(userBookCollect);
        }
        return msg;
    }
}
